<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<script>
   const date=new Date("2021-12-19 21:47:50");
   //这些都可以返回时间戳
   console.log(date*1);
   console.log(Number(date));
   console.log(date.valueOf());
   console.log(date.getTime());

   //怎么将时间戳变为时间呢？
   let timestamp=date.valueOf();
   console.log(timestamp);//时间戳
   console.log(new Date(timestamp));//(Object)Sun Dec 19 2021 21:47:50 GMT+0800 (中国标准时间)
   console.log( Date(timestamp));//(String)Sun Dec 19 2021 21:47:50 GMT+0800 (中国标准时间)
;
</script>
</body>
</html>